<!--
新闻中心增加
 add by yyp 2019-05-10
-->
<template lang="pug">
  kalix-dialog.user-add(bizKey="News" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL" v-bind:submitBefore="submitBefore")
    div.el-form(slot="dialogFormSlot" style=" width:60%;margin:auto;")
      el-form-item(label="新闻标题" prop="newTitle" label-width="120px" v-bind:rules="rules.newTitle")
        el-input(v-model="formModel.newTitle" style="width:80%")
      el-form-item(label="新闻日期" prop="newDate" label-width="120px" v-bind:rules="rules.newDate")
        kalix-date-picker(v-model="formModel.newDate" style="width:80%" type="date")
        <!--el-date-picker(v-model="formModel.newDate" type="date" placeholder="选择日期")-->
      el-form-item.short(label="新闻图片" prop="newUrl" v-bind:label-width="labelWidth")
        kalix-clansman-upload(:action="action" v-on:filePath="getFilePath" fileType="img"  :fileList="fileList" tipText="只能上传jpg/png文件")
        <!--kalix-clansman-upload(:action="action" v-model="formModel.newUrl" ref="clearUpload" v-on:filePath="getFilePath" v-on:selectChange="setGroup" :fileList="fileList" fileType="img" tipText="只能上传图片文件")-->
        <!--kalix-img-upload.img-margin(v-model="formModel.newUrl" readonly="readonly" v-on:ImgDel="ImgDel")-->
      el-form-item(label="新闻详情" prop="newDetails" label-width="120px" v-bind:rules="rules.newDetails")
        el-input(v-model="formModel.newDetails" style="width:80%"  type="textarea")
      el-form-item(label="新闻排序" prop="newOrder" label-width="120px" v-bind:rules="rules.newOrder")
        el-input(v-model="formModel.newOrder" style="width:80%")
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {NewsURL} from '../../config.toml'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  export default {
    name: 'newsAdd',
    components: {KalixSelect, KalixClansmanUpload},
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        action: baseURL + '/camel/rest/upload',
        rules: {
          name: [{required: true, message: '请输入名称', trigger: 'blur'}]
        },
        targetURL: NewsURL,
        filePathArr: [],
        fileList: [],
        labelWidth: '110px'
      }
    },
    mounted() {
    },
    methods: {
      getFilePath(filePath, fileName) {
        // console.log('--getFilePath---', filePath)
        // console.log('--fileName---', fileName)
        // this.formModel.newUrl = filePath
        // this.formModel.imgName = fileName
        this.filePathArr.push(filePath)
        // this.fileNameArr.push(fileName)
      },
      submitBefore(baseDialog, callBack) {
        let filePath = ''
        if (this.filePathArr.length > 0) {
          this.filePathArr.forEach(e => {
            filePath += e + ','
          })
          filePath = filePath.substr(0, filePath.length - 1)
        }
        console.log('filePath==========', filePath)
        baseDialog.formModel.newUrl = filePath
        callBack()
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 70%
    margin auto
    .el-input
      width 70%
    .radio
      margin-left 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
</style>
